<template>
  <el-cascader
    :options="treeOptions"
    v-bind="$attrs"
    v-on="$listeners"
    v-model="fieldValue"
    :props="{
      label:labelKey,
      value:idKey,
      checkStrictly: checkStrictlyType
    }"
    >
  </el-cascader>
</template>

<script>
  import {buildTree} from '@/utils/convert'

  export default {
    props: {
      options: {
        type: Array,
        default() {
          return []
        }
      },
      // 列表数据转化成树结构要用到的父级id值
      parentId: {
        type: [Number, String],
        default: null
      },
      value: {
        type: [Array,Number],
        default() {
          return [];
        }
      },
      idKey: {
        type: String,
        default: 'id'
      },
      parentIdKey: {
        type: String,
        default: 'pid'
      },
      labelKey: {
        type: String,
        default: 'title'
      },
      checkStrictlyType:{
        type:Boolean,
        default:true
      }
    },
    data() {
      return {}
    },
    computed: {
      treeOptions() {
        // console.log(this.options, parentId, this.idKey, this.parentIdKey);
        // return buildTree(this.options, 0, this.idKey, this.parentIdKey)
        return this.options;
      },
      fieldValue: {
        get() {
          console.log( this.value,'1111111111111111');
          return this.value
        },
        set(val) {
          this.$emit('input', val)
        }
      }
    }
  }
</script>

